package
{
	import chapter1.Chapter1Demp;
	
	import chapter4.Chapter4Demp;
	
	import chapter5.Chapter5Demp;
	
	import chapter6.Chapter6Demo;
	
	import chapter7.Chapter7Demp;
	
	import chapter8.Chapter8Demp;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import testChapter.TestChapter;
	
	import utils.IRender;
	import utils.Molehill_obj_parser;
	
	[SWF(backgroundColor="#93a9b4", frameRate="60")]
	public class EngineAS3 extends Sprite
	{
		private var renderObject:IRender;
		public function EngineAS3()
		{
			if (stage != null)
				init();
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}
		private function init(event:Event=null):void{
			if (hasEventListener(Event.ADDED_TO_STAGE))
				removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			renderObject = new Chapter5Demp(stage);
			
			renderObject.addEventListener(Event.COMPLETE,onCreatComplete);
			
		}
		
		private function onCreatComplete(event:Event):void{
			this.addEventListener(Event.ENTER_FRAME,enterFrame);
		}
		
		private function enterFrame(event:Event):void{
			renderObject.render();
		}
		
		
	}
}
